package com.yue.lin.service;

import com.yue.lin.entity.Student;
import com.yue.lin.mapper.StudentMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author zhengyl
 * @description
 * @date 2020-04-23 10:45
 */
@Service
public class StudentService {
    @Autowired
    private StudentMapper studentMapper;

    public List<Student> list() {
        return studentMapper.list();
    }

    public List<Student> list2(String name, String phone) {
        return studentMapper.list2(name, phone);
    }

    public List<Student> list3(String name, String phone) {
        return studentMapper.list3(name, phone);
    }

    public List<Student> list4(String name, String phone) {
        Map params = new HashMap<String, Object>();
        if (StringUtils.isNotBlank(name)) {
            params.put("name", name);
        }
        if (StringUtils.isNotBlank(phone)) {
            params.put("phone", phone);
        }
        return studentMapper.list4(params);
    }

    public List<Student> list5(String name, String phone) {
        Student student = new Student();
        student.setName(name);
        student.setPhone(phone);
        return studentMapper.list5(student);
    }
}
